The present invention relates to motion vector encoding and decoding methods, motion vector encoding and decoding apparatuses, and storage media storing motion vector encoding and decoding programs. These methods, apparatuses, and storage media are applied to a motion-picture encoding method using motion-compensating interframe prediction.
The interframe predictive coding method for motion pictures (i.e., video data) is known, in which an already-encoded frame is used as a prediction signal so as to reduce temporal redundancy. In order to improve the efficiency of the time-based prediction, a motion-compensating interframe prediction method is used in which a motion-compensated picture signal is used as a prediction signal. The motion vector necessary for motion compensation in the decoding operation is encoded and transmitted to the decoding side.
Generally, the motion compensation is executed for each unit area such as a block, and each area has an individual motion vector. It is known that the motion vectors belonging to neighboring areas have a higher correlation. Therefore, in practice, the motion vector of an area to be encoded is predicted based on the motion vector of an area which neighbors the area to be encoded, and a prediction error is transmitted so as to reduce the redundancy of the motion vector. The following explanations refer to the moving-picture coding method ISO/IEC 11172-2 (MPEG-1) as an example. In MPEG-1, the motion compensation is performed for each block, and the motion vector of a block to be encoded (i.e., a target block) is predicted based on the motion vector of the block immediately before the target block. The motion vector used in MPEG-1 is defined in an orthogonal coordinate system, and has horizontal component x and vertical component y. The prediction errors Xd and Yd of these components are calculated using the following equations.
xd=xixe2x88x92xixe2x88x921xe2x80x83xe2x80x83(1)
yd=yixe2x88x92yixe2x88x921xe2x80x83xe2x80x83(2)
where xi and yi are components of the motion vector of the target block, and xixe2x88x921 and yixe2x88x921 are components of the motion vector of the block immediately before the target block.
In general motion pictures, as shown in FIG. 11, distributions of the prediction error components x and yi are respectively concentrated near zero; therefore, variable-length encoding in which the shortest code length is xe2x80x9c0xe2x80x9d is performed, and encoded data are transmitted to the decoding side.
When decoding the motion vector, the prediction error which was variable-length-encoded is extracted from the encoded data sequence, and the motion vector of the target block to be decoded is decoded by adding the prediction error to the motion vector of the block which was previously decoded. See the following equations.
xi=xixe2x88x921+xdxe2x80x83xe2x80x83(3)
yi=yixe2x88x921+ydxe2x80x83xe2x80x83(4)
where xi and yi are components of the motion vector of the target block, and xixe2x88x921 and yixe2x88x921 are components of the motion vector of the block which was decoded immediately before the target block.
FIG. 12 shows the distribution of a difference vector in general motion pictures. As shown in FIG. 12, the distribution of the vector indicating the prediction error is concentrated to the origin (0, 0).
In order to shorten the length of code near the origin (0, 0) in the conventional method, short codes must be assigned to both horizontal and vertical components near xe2x80x9c0xe2x80x9d. This means that short codes are also assigned to the vectors near the X and Y axes. Here, the example code lengths assigned to each vector in the conventional method are shown in FIG. 13. When comparing FIG. 13 with FIG. 12, it is clear that the assignment of code does not agree with the actual distribution of the difference vector.
As explained above, the conventional method has a problem in which it is impossible to efficiently assign codes based on the distribution of the difference vector.
Therefore, the objective of the present invention is to provide motion vector encoding and decoding methods to reduce the amount of generated code with respect to the motion vector.
The present invention relates to the motion vector predictive encoding method, the motion vector predictive encoding apparatus, and the motion vector predictive encoding program stored in a computer-readable storage medium, which are applied to the motion-picture encoding method using the motion-compensating interframe prediction. In the present invention, when a motion vector is encoded, the vector is represented using a coordinate system, such as polar coordinates, consisting of length and direction components of the vector, and each component is encoded. If the motion vector to be encoded is represented using an orthogonal coordinate system, the motion vector is converted to have length and direction components, and then each component is encoded.
The possible values for the direction component change depending on the length component; thus, the table used for encoding the direction component is changed according to the length component. Therefore, the direction component is encoded after the length component is encoded.
The length component may be one of the sum of absolute values, the sum of squares, the square root of the sum of squares, and the maximum value with respect to components of the motion vector in an orthogonal coordinate system. The following are examples for calculating the length component of the vector.
Sum of absolute values (refer to FIG. 8)
rabs=|x|+|y|xe2x80x83xe2x80x83(5)
Sum of squares (refer to FIG. 9)
rsqr=x2+y2xe2x80x83xe2x80x83(6)
Square root of the sum of squares (refer to FIG. 9: in this case, each value in the brackets indicates r)
rsqr=(x2+y2)xe2x80x83xe2x80x83(7)
Maximum value (refer to FIG. 10)
rmax=max (x, y)xe2x80x83xe2x80x83(8)
In the above equations (5) to (8), x indicates the horizontal component of the vector, while y indicates the vertical component of the vector. In addition, the calculating method to be used can be partially changed if the method can be applied to all vectors.
On the other hand, in the motion vector decoding method, the motion vector decoding apparatus, and the motion vector decoding program stored in a computer-readable storage medium in the present invention, the length component and the direction component of the motion vector are decoded based on motion vector information which is encoded using the motion vector encoding method, the motion vector predictive encoding apparatus, and the motion vector predictive encoding program stored in a computer-readable storage medium.
The table for decoding the direction component is selected in accordance with the length component; thus, the direction component is decoded after the length component is decoded.
According to the present invention, it is possible to assign codes in consideration of the distribution of the prediction error vector. As a result, the amount of generated code of the motion vector can be reduced.